package PTA_JAVA.JavaB.Javademo23;

import sun.reflect.generics.tree.Tree;

import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int seed1 = sc.nextInt();
        Set<Integer> Badminton=getBadmintonList(seed1);
        int seed2 = sc.nextInt();
        Set<Integer> Basketball = getBasketballList(seed2);
        System.out.println(Badminton);
        System.out.println(Basketball);
        Set<Integer> list =new TreeSet<>();
        //取并集
        list.addAll(Badminton);
        list.addAll(Basketball);
        System.out.println(list.size()+"\n"+list);
        //取交集
        Set<Integer> list1 =new TreeSet<>();
        list1.addAll(Badminton);
        list1.retainAll(Basketball);
        System.out.println(list1.size()+"\n"+list1);
        //取外集
        Set<Integer> list2 =new TreeSet<>();
        for (int i = 1; i <= 1000; i++) {
            list2.add(i);
        }
        list2.removeAll(list);
        System.out.println(list2.size()+"\n"+list2);
    }
    public static Set<Integer> getBadmintonList(int seed){
        Set<Integer> set = new TreeSet<Integer>();
        Random rd = new Random(seed);
        while(set.size()<300) {
            set.add(rd.nextInt(1000)+1);
        }
        return set;
    }

    public static Set<Integer> getBasketballList(int seed){
        Set<Integer> set = new TreeSet<Integer>();
        Random rd = new Random(seed);
        while(set.size()<400) {
            set.add(rd.nextInt(1000)+1);
        }
        return set;
    }

}
